﻿<navigation:Page x:Class="Examples.Views.DashboardView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"
                 xmlns:converter="clr-namespace:Examples.Converters"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:mvvm="clr-namespace:Examples.ViewModels"
                 d:DesignWidth="640" d:DesignHeight="480"
                 Title="Dashboard View"
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <navigation:Page.Resources>
        <converter:EventTypeConverter x:Key="eventConverter"/>
        <converter:EventTypeDimConverter x:Key="eventDimConverter"/>
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot">
        <!--<Grid.DataContext>
            <mvvm:DashboardViewModel/>
        </Grid.DataContext>-->

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="32" />
            <RowDefinition Height="*" />
            <RowDefinition Height="10" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Might be able to use this and the ItemTemplate somewhere else!
            <ListBox x:Name="EventListBox"
                 ItemsSource="{Binding Path=EventList}"
                 SelectedItem="{Binding Path=SelectedEvent}"
                 VerticalAlignment="Stretch"
                 HorizontalAlignment="Stretch"
                 MinWidth="170"
                 Grid.Column="0"
                 ItemTemplate="{StaticResource EventListBoxDataTemplate}"/>-->

        <StackPanel x:Name="ActionsStackPanel"
                    Orientation="Horizontal"
                    HorizontalAlignment="Left">

            <HyperlinkButton Content="Show Events"
                             VerticalAlignment="Center"
                             Command="{Binding ShowEventsCommand, Mode=OneWay}"/>

            <HyperlinkButton Content="Show Exceptions"
                             Margin="10,0,0,0"
                             VerticalAlignment="Center"
                             Command="{Binding ShowExceptionsCommand, Mode=OneWay}"/>

        </StackPanel>

        <sdk:DataGrid x:Name="EventDataGrid"
                      Grid.Row="1"
                      ItemsSource="{Binding Path=EventList}"
                      SelectedItem="{Binding Path=SelectedEventMetadata, Mode=TwoWay}"
                      VerticalAlignment="Stretch"
                      HorizontalAlignment="Stretch"
                      AutoGenerateColumns="False"
                      AlternatingRowBackground="Transparent"
                      RowBackground="Transparent"
                      RowStyle="{StaticResource EventTypeColoredDataGridRowStyle}">


            <sdk:DataGrid.Columns>

                <sdk:DataGridTextColumn Header="Time"
                                        Binding="{Binding Path=EventTime}"/>

                <sdk:DataGridTextColumn Header="Type"
                                        Binding="{Binding Path=EventType}"/>

                <sdk:DataGridTextColumn Header="Code"
                                        
                                        Binding="{Binding Path=EventCode}"/>

                <sdk:DataGridTextColumn Header="Detail Code"
                                        Binding="{Binding Path=EventDetailCode}"/>

            </sdk:DataGrid.Columns>

        </sdk:DataGrid>

        <sdk:GridSplitter Name="ViewGridSplitter"
                          Grid.Row="2"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Center" />

        <ScrollViewer VerticalAlignment="Stretch"
                      Grid.Row="3">

            <StackPanel x:Name="DetailsStackPanel"
                        Background="{Binding Path=EventType, Converter={StaticResource eventConverter}}"
                        VerticalAlignment="Stretch"
                        HorizontalAlignment="Stretch"
                        DataContext="{Binding Path=SelectedEventDetails}">

                <StackPanel x:Name="DetailsTopGroupStackPanel"
                            Background="{Binding Path=EventType, Converter={StaticResource eventDimConverter}}"
                            Margin="10, 10, 10, 10"
                            Orientation="Horizontal">

                    <Grid HorizontalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="160"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="160"/>
                        </Grid.ColumnDefinitions>

                            <TextBlock Text="{Binding Path=EventTime}"
                                       Grid.Row="0"
                                       Grid.Column="0"
                                       Margin="10,10,0,10"/>

                            <TextBlock Text="{Binding Path=EventTimeUTC}"
                                       Grid.Row="1"
                                       Grid.Column="0"
                                       Margin="10,0,10,10"/>

                            <TextBlock Text="{Binding Path=EventType}"
                                       Grid.Row="0"
                                       Grid.Column="1"
                                       Margin="10,10,0,10"/>

                            <StackPanel Orientation="Horizontal"
                                        Grid.Row="1"
                                        Grid.Column="1"
                                        Margin="10,0,10,10">

                                <TextBlock Text="{Binding Path=EventCode}" />

                                <TextBlock Text="{Binding Path=EventDetails}"
                                           Margin="10,0,0,0"/>

                            </StackPanel>

                            <TextBlock Text="{Binding Path=EventSequence}"
                                       HorizontalAlignment="Right"
                                       Grid.Row="0"
                                       Grid.Column="2"
                                       Margin="10,10,0,10"/>

                            <TextBlock Text="{Binding Path=EventOccurance}"
                                       HorizontalAlignment="Right"
                                       Grid.Row="1"
                                       Grid.Column="2"
                                       Margin="10,0,10,10"/>
                        
                    </Grid>

                </StackPanel>

                <StackPanel x:Name="DetailsMessageStackPanel"
                            Background="{Binding Path=EventType, Converter={StaticResource eventDimConverter}}"
                            Margin="10,0,10,10"
                            VerticalAlignment="Stretch"
                            HorizontalAlignment="Stretch">

                    <TextBlock Text="{Binding Path=Message}"
                               Margin="10,10,10,10"
                               TextWrapping="Wrap"
                               ScrollViewer.VerticalScrollBarVisibility="Auto" />

                </StackPanel>

                <StackPanel x:Name="DetailsMiddleStackPanel"
                            Background="{Binding Path=EventType, Converter={StaticResource eventDimConverter}}"
                            Margin="10,0,10,10"
                            Orientation="Horizontal"
                            VerticalAlignment="Top"
                            HorizontalAlignment="Stretch">

                    <TextBlock Text="{Binding Path=MachineName}"
                               Margin="10,0,5,0"
                               HorizontalAlignment="Left" />

                    <TextBlock Text="{Binding Path=RequestURL}"
                               Margin="5,0,5,0"
                               HorizontalAlignment="Left" />

                    <TextBlock Text="{Binding Path=ExceptionType}"
                               Margin="5,0,10,0"
                               HorizontalAlignment="Left" />

                </StackPanel>

                <StackPanel x:Name="DetailsBottomStackPanel"
                            Background="{Binding Path=EventType, Converter={StaticResource eventDimConverter}}"
                            Margin="10,0,10,10"
                            VerticalAlignment="Stretch"
                            HorizontalAlignment="Stretch">

                    <TextBlock Text="{Binding Path=Details}"
                               Margin="10,10,10,10"
                               TextWrapping="Wrap"
                               ScrollViewer.VerticalScrollBarVisibility="Auto" />

                </StackPanel>

            </StackPanel>

        </ScrollViewer>

    </Grid>

</navigation:Page>